package problems.solved;

public class Problem28 {
    private static final int END = 1001;
    private static final int TARGET = (END*END);
    
    public static void main(String[] args) {
        long sum = 1;
        int add = 2;
        int next = 1;
        
        while(next < TARGET) {
            for (int i = 0; i < 4; i++) {
                next += add;
                sum += next;
            }
            add += 2;
        }
        System.out.println(sum); // 669171001
    }
}